package com.lx.pc.service.account.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.account.AccountEntity;
import com.lx.pc.domain.vo.account.AccountVo;
import com.lx.pc.mybatis.repository.account.AccountRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.account.IAccountService;
import com.lx.pc.utils.OmsPage;

@Service("accountService")
public class AccountServiceImpl extends AbstractService<AccountEntity, AccountVo, BigInteger, AccountRepository> implements IAccountService{

	@Override
	public int findByAccountCount(AccountVo account) {

		return repository.findByAccountCount(account);
	}

	@Override
	public OmsPage<AccountVo> findByAccount(AccountVo account, Integer page, Integer size) {
		OmsPage<AccountVo> pages = new OmsPage<AccountVo>();
		pages.setTotal(repository.findByAccountCount(account));
		List<AccountEntity> list = repository.findByAccount(account,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		return pages;
	}

	@Override
	public AccountVo findByUserId(String userId) {
		return etoV(repository.findByUserId(userId));
	}

}
